package com.simba.server.task;

import com.simba.common.log.LogUtil;
import com.simba.server.components.ChannelsManager;
import org.apache.log4j.Logger;

public class KeepAliveThread extends Thread
{
	private final static Logger logger = Logger.getLogger(KeepAliveThread.class);
	private static final int RECONNECT_INTERVAL = 3000;

	public KeepAliveThread()
	{
		this.setName("Keep-Alive-Thread");
	}

	@Override
	public void run()
	{
		while (!Thread.currentThread().isInterrupted())
		{
			try
			{
				Thread.sleep(KeepAliveThread.RECONNECT_INTERVAL);
				ChannelsManager.getInstance().handlerOverTimeLink();
			}
			catch (Exception ex)
			{
				if (ex instanceof InterruptedException)
				{
					Thread.currentThread().interrupt();
				}
				LogUtil.LogError(logger, "Catch an exception [" + ex.getMessage() + "]");
			}
		}
	}

}
